package com.qf.service.impl;

import com.qf.mapper.UserMapper;
import com.qf.mapper.UserMapper2;
import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.service.UserService2;
import com.qf.utils.MapperUtils;

import java.io.IOException;
import java.util.List;

public class UserServiceImpl2 implements UserService2 {
    @Override
    public List<User> findAll() throws IOException {

        UserMapper2 userMapper2 = MapperUtils.getMapper(UserMapper2.class);

        List<User> users = userMapper2.findAll();

        MapperUtils.close();

        return users;
    }

    @Override
    public User findById(Integer id) throws IOException {
        UserMapper2 userMapper2 = MapperUtils.getMapper(UserMapper2.class);

        User user = userMapper2.findById(id);

        MapperUtils.close();

        return user;
    }

    @Override
    public int insert(User user) throws IOException {
        UserMapper2 userMapper2 = MapperUtils.getMapper(UserMapper2.class);

        int count = userMapper2.insert(user);

        MapperUtils.close();

        return count;
    }

    @Override
    public int update(User user) throws IOException {
        UserMapper2 userMapper2 = MapperUtils.getMapper(UserMapper2.class);

        int count = userMapper2.update(user);

        MapperUtils.close();

        return count;
    }

    @Override
    public int delete(Integer id) throws IOException {
        UserMapper2 userMapper2 = MapperUtils.getMapper(UserMapper2.class);

        int count = userMapper2.delete(id);

        MapperUtils.close();

        return count;
    }

    @Override
    public List<User> findByConditions(User user) throws IOException {
        return null;
    }

    @Override
    public List<User> findByNameAndAge(String name, Integer age) throws IOException {
        return null;
    }

    @Override
    public List<User> findByIds(List<Integer> ids) throws IOException {
        return null;
    }

    @Override
    public List<User> findByIds2(Integer... ids) throws IOException {
        return null;
    }
}
